package 力扣._94_二叉树中序遍历;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    private class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    List<Integer> list = new ArrayList<>();

    void minorder(TreeNode root) {
        if (root == null)
            return;
        if (root.left != null)
            minorder((root.left));
        list.add(root.val);
        if (root.right != null)
            minorder((root.right));
    }

    public List<Integer> inorderTraversal(TreeNode root) {
        minorder(root);
        return list;
    }
}
